package com.wl.mr.sortmub;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SortNumReducer extends Reducer<LongWritable, NullWritable,LongWritable,LongWritable> {

    LongWritable lineSum = new LongWritable(1);

    @Override
    protected void reduce(LongWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) {
            context.write(lineSum,key);
            lineSum = new LongWritable(lineSum.get() + 1);
        }

    }
}
